package com.teamone.addressbook.Model;

import com.teamone.addressbook.Utilities.Utility;

public class RegisterAddrEty {

	private final Utility u;
	
	public RegisterAddrEty(Utility u)
	{
		this.u = u;
	}
	
	public void registerAddress(Address adr)
	{
		int newID = -1;
		
		try
		{
			newID = (Integer)u.getSqlMapClient().queryForObject("getNewID");
			newID++;
		}
		catch(Exception e)
		{
			newID = 1;
		}
		
		adr.setID(newID);
		
		try
		{
			u.getSqlMapClient().insert("insertAddress", adr);
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
	}
}
